<?php

	include_once('../sys/sys.php');
	header('Content-Type: text/html; charset=utf-8');
	$action = $_GET['action'];
	$tid = $_GET['tid'];
	
	if(!is_numeric($tid) || $tid < 0){
		show_normal_mesR('TAG ID错误','TAG ID错误','TAG查询');
	}
	//开始获取该ID下的图片
	$DB->build_query(array(
			'select' 	=> '*',
			'from'		=> 'nonadmphotos',
			'where'		=>	'uid=' . $tid,
	));
	$qid = $DB->exec_query();
	$pics = '';
	while ($row = $DB->fetch_row($qid)) {
		$nums = $row['count'];
		$pre_url = $row['url'];
		for($i=1;$i<=$nums;$i++){
			$pics .= $pre_url . get_pre_nums(7,$i) . ".jpg\r\n";
		}
	}
	if($action == 'getpicurls'){
		echo '<textarea rows="20" cols="80" tabindex="2" class="txtarea">' . $pics . '</textarea>';
	}
	else if($action == 'getpicfiles'){
		header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
		header("Content-Type: text/plain; charset=UTF-8");
		header("Content-Disposition: attachment;filename=\"$tid.lst\"");
		echo $pics;
		
	}
	//更新访问计数
	$result = $DB->build_and_exec_query(
			array(
				'select' 	=> 'scount',
				'from'		=> 'nonadmtags',
				'where'		=>	'id=' . $tid,
			)
	);
	
	$where = 'id= ' . $tid .'';
	$DB->do_update('nonadmtags',
		array(					  
		   'scount'				=> $result['scount'] + 1,
		 ),
		 $where
	);

	
?>